import 'package:flutter/material.dart';
import 'package:ytbusiness/config/style.dart';
import 'package:ytbusiness/utils/helper.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/widgets.dart';

///分类列表
class CategoryList extends StatefulWidget {
  //{title}
  final Map<String, dynamic> arguments;

  const CategoryList({Key key, this.arguments}) : super(key: key);

  @override
  _CategoryListState createState() => _CategoryListState();
}

class _CategoryListState extends State<CategoryList> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: YTStyle.bgColor,
      appBar: customAppBar(context, title: widget.arguments["title"] as String),
      body: Container(
        child: ListView.builder(
            shrinkWrap: true,
            itemCount: 7,
            itemBuilder: (context, index) {
              return GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    switch (int.parse(widget.arguments["type"] as String)) {
                      //询价中
                      case 0:
                        urlPush(context, "yuntu://procurement_enquiry");
                        break;
                      //待确认
                      case 1:
                        urlPush(context, "yuntu://await_confirm");
                        break;
                      //待支付
                      case 2:
                        urlPush(context, "yuntu://await_pay");
                        break;
                      //待收货
                      case 3:
                        urlPush(context, "yuntu://procurement_await_deliver");
                        break;
                      //已收货
                      case 4:
                        urlPush(context, "yuntu://procurement_already_deliver");
                        break;
                      //待评价
                      case 5:
                        urlPush(context, "yuntu://procurement_await_evaluate");
                        break;
                      //已完成
                      case 6:
                        urlPush(context, "yuntu://procurement_done");
                        break;
                    }
                  },
                  child: item(index));
            }),
      ),
    );
  }

  //列表项
  Widget item(int index) {
    return Container(
      margin: EdgeInsets.only(
          top: setWidth(10), left: setWidth(10), right: setWidth(10)),
      padding: EdgeInsets.only(
          top: setWidth(20),
          left: setWidth(12),
          right: setWidth(12),
          bottom: setWidth(20)),
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(4)),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  child: Text(
                    "订单编号：AE9998820031",
                    style: TextStyle(
                        color: Color(0xff323232), fontSize: setSp(15)),
                  ),
                ),
                Container(
                  child: Text(
                    widget.arguments["title"] as String,
                    style: TextStyle(
                        color: Color(0xffFF921A), fontSize: setSp(14)),
                  ),
                )
              ],
            ),
          ),
          SizedBox(
            height: setWidth(16),
          ),
          Container(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  child: Text(
                    "车辆型号：路虎极光",
                    style: TextStyle(
                        color: Color(0xff323232), fontSize: setSp(15)),
                  ),
                ),
                Container(
                  child: Text(
                    "2020-11-23 14:02",
                    style: TextStyle(
                        color: Color(0xff989898), fontSize: setSp(12)),
                  ),
                )
              ],
            ),
          ),
          SizedBox(
            height: setWidth(16),
          ),
          Container(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Container(
                  child: Text(
                    "采购件数：19",
                    style: TextStyle(
                        color: Color(0xff323232), fontSize: setSp(15)),
                  ),
                ),
              ],
            ),
          ),
          SizedBox(
            height: setWidth(29),
          ),
          Container(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Container(
                  child: Text(
                    "共9个供应商报价，已确认(5/12)个订单",
                    style: TextStyle(
                        color: Color(0xff1666F1), fontSize: setSp(15)),
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
